﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UniMana.Data.Quiz;
using System.Data.Linq;

namespace UniMana.Lib.Quiz
{
    public static class Quiz_QuestionData
    {
        public static IQueryable GetListByKeyAndType(this Table<Quiz_Question> _nQuestion, int _iSubjectKey, int _iType)
        {
            return _nQuestion.Where(p => p.Training_SubjectKey == _iSubjectKey
                                     && p.Quiz_QuestionTypeKey == _iType);
        }

        //Lấy danh sách câu hỏi đã được duyệt
        public static IQueryable GetListApproval(this Table<Quiz_Question> _nQuestion, int _iSubjectKey, int _iType)
        {
            return _nQuestion.Where(p => p.Training_SubjectKey == _iSubjectKey
                                     && p.Quiz_QuestionTypeKey == _iType
                                     && p.Status == true);
        }


        //Lấy danh sách câu hỏi chưa được duyệt
        public static IQueryable GetListDisApproval(this Table<Quiz_Question> _nQuestion, int _iSubjectKey, int _iType)
        {
            return _nQuestion.Where(p => p.Training_SubjectKey == _iSubjectKey
                                     && p.Quiz_QuestionTypeKey == _iType
                                     && p.Status == false);
        }

        //Lấy danh sách câu hỏi mà chủ đề nằm trong 1 List<int> cho trước
        public static IQueryable GetListWhereIn(this Table<Quiz_Question> _nQuestion, List<int?> _iTopicKeys)
        {
            var result = from ques in _nQuestion
                         where _iTopicKeys.Contains(ques.Quiz_SubjectTopicKey)
                         select new
                         {
                             ques.ID
                         };
            return result;
        }

    }
}
